var isRefreshOddsTable = true;

function GetWagerTable(){
	if(isGameStart == "N")return false;
	if(isRefreshOddsTable == false)return ClearTextField();

	var objWTable = document.getElementById("wager_table"), i = 0, j = 0, intNum = 0, strNum = "", strDisabled = "", StopClass = "";
	var ArrStake = new Array();

	with(objWTable)	{
		for(intNum = 0; intNum <= 119; intNum++)	{
			if(null != document.ShowOddsForm["Odds"+intNum.toString()]){
				ArrStake[intNum] = document.ShowOddsForm["Odds"+intNum.toString()].value;
			}else{
				ArrStake[intNum] = "";
			}

		}
		while(rows.length > 1)	deleteRow(rows.length - 1);
			
		for(i = 0; i <= 9; i++)	{
			newTR = insertRow(rows.length);

			for(j = 0; j <= 11; j++)	{
				intNum = j *10 + i;
				
				newTR.className = "mcen";
				with(newTR){
					newTD = insertCell(j);
					newTD.id = "NumberValue"+intNum.toString();
					newTD.className = "mbline";
					newTD.innerHTML = "<input name=\"ChoiceNumber["+intNum.toString()+"]\" value=\"\" class=\"zamoney\" type=\"text\" onkeypress=\"return CheckNumKey()\" onKeyUp=\"return CheckNumKey()\" onclick=\"this.blur()\" size=\"3\">";
				} //with(newTR)
			}
		}
	} //with(objWTable)
	isRefreshOddsTable = false;
}

function CheckNumKey(){
	return false;
}

function InitAction(){
	GetWagerTable();
}

function ChoiceAllNumber(isCheck){
	with(document.ShowOddsForm){
		for(var i = 0; i < ChoiceNo.length; i++){
			ChoiceNo[i].checked = isCheck;
		}
	}
}

function ClearTextField(){
	var i = 0, j = 0;
	for(i = 0; i <= 9; i++)	{
		for(j = 0; j <= 11; j++)	{
			intNum = j *10 + i;
			document.ShowOddsForm["ChoiceNumber["+intNum.toString()+"]"].value = '';
		}
	}
	document.HideOddsForm["ChoiceNumber"].value = '';
	return true;
}

var arrCNo = new Array(10);
function CombinationNum(){
	var intCType = 0; //0 => 組三轉直, 1 => 組六轉直, 2 => 包車
	if(document.ShowOddsForm.ChoiceType[1].checked == true)intCType = 1;
	if(document.ShowOddsForm.ChoiceType[2].checked == true)intCType = 2;

	var k = 0; //組數
	var intTmp = 0;
	arrCNo = [null, null, null, null, null, null, null, null, null, null];
	for(var i = 0; i < 10; i++){
		//if(eval("document.ShowOddsForm.ChoiceNo["+i+"].checked") == true){
		if(document.ShowOddsForm.ChoiceNo[i].checked == true){
			//alert(i);
			arrCNo[k] = i;
			k++;
		}
	}

	var strAllNum = '';
	for(var i = 0; i < 10; i++){
		for(var i1 = i; i1 < 10; i1++){
			for(var i2 = i1; i2 < 10; i2++){
				var strNumber = '' + i + '' + i1 + '' + i2;
				var intSameNo = 0;
				if(i == i1)intSameNo++;
				if(i1 == i2)intSameNo++;
				if(i2 == i)intSameNo++;
				if(intCType == 0 && intSameNo == 1){//组三
					for(var k2 = 0; k2 < k; k2++){
						if(arrCNo[k2] === null)continue;
						if(i == arrCNo[k2] || i1 == arrCNo[k2] || i2 == arrCNo[k2]){
							strAllNum = strAllNum + strNumber + ',';
							break;
						}
					}
				}
				if(intCType == 1 && intSameNo == 0){//组六
					for(var k2 = 0; k2 < k; k2++){
						if(arrCNo[k2] === null)continue;
						if(i == arrCNo[k2] || i1 == arrCNo[k2] || i2 == arrCNo[k2]){
							strAllNum = strAllNum + strNumber + ',';
							break;
						}
					}
				}
				if(intCType == 2){//包車
					intTmp = 0;
					for(var k2 = 0; k2 < k; k2++){
						if(arrCNo[k2] === null)continue;
						if(i == arrCNo[k2] || i1 == arrCNo[k2] || i2 == arrCNo[k2]){
							intTmp++;
						}
					}
					if(intTmp >= 3){
						strAllNum = strAllNum + strNumber + ',';
					}
				}
			}
		}
	}

	if(strAllNum.length > 0){strAllNum = strAllNum.substring(0, strAllNum.length - 1);}
	var arrAllNum = new Array();
	arrAllNum = strAllNum.split(",");
	ClearTextField();
	document.HideOddsForm["ChoiceNumber"].value = strAllNum;
	for (var intNum = 0; intNum < arrAllNum.length; intNum++) {
		document.ShowOddsForm["ChoiceNumber["+intNum.toString()+"]"].value = arrAllNum[intNum];
	}
}

function FinalCheck(){
	if (document.HideOddsForm["ChoiceNumber"].value == '')	{
		alert(noNumber);
		return false;
	}
	document.HideOddsForm.submit();
}